package com.tudouji.project.bill.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.bill.domain.Whinformitem;
import com.tudouji.project.bill.service.IWhinformitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 入库单明细Controller
 * 
 * @author wf
 * @date 2021-01-07
 */
@RestController
@RequestMapping("/bill/whinformitem")
public class WhinformitemController extends BaseController
{
    @Autowired
    private IWhinformitemService whinformitemService;

    /**
     * 查询入库单明细列表
     */
    @PreAuthorize("@ss.hasPermi('bill:whinformitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(Whinformitem whinformitem)
    {
        startPage();
        List<Whinformitem> list = whinformitemService.selectWhinformitemList(whinformitem);
        return getDataTable(list);
    }

    /**
     * 导出入库单明细列表
     */
    @PreAuthorize("@ss.hasPermi('bill:whinformitem:export')")
    @Log(title = "入库单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Whinformitem whinformitem)
    {
        List<Whinformitem> list = whinformitemService.selectWhinformitemList(whinformitem);
        ExcelUtil<Whinformitem> util = new ExcelUtil<Whinformitem>(Whinformitem.class);
        return util.exportExcel(list, "whinformitem");
    }

    /**
     * 获取入库单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('bill:whinformitem:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(whinformitemService.selectWhinformitemById(guid));
    }

    /**
     * 新增入库单明细
     */
    @PreAuthorize("@ss.hasPermi('bill:whinformitem:add')")
    @Log(title = "入库单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Whinformitem whinformitem)
    {
        return toAjax(whinformitemService.insertWhinformitem(whinformitem));
    }

    /**
     * 修改入库单明细
     */
    @PreAuthorize("@ss.hasPermi('bill:whinformitem:edit')")
    @Log(title = "入库单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Whinformitem whinformitem)
    {
        return toAjax(whinformitemService.updateWhinformitem(whinformitem));
    }

    /**
     * 删除入库单明细
     */
    @PreAuthorize("@ss.hasPermi('bill:whinformitem:remove')")
    @Log(title = "入库单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(whinformitemService.deleteWhinformitemByIds(guids));
    }
}
